﻿using B.T.Smark.APIRead.Applications.Command;
using B.T.Smark.Domain;
using B.T.Smark.ErrorCode;
using B.T.Smark.Infartructrue.Interfaces;
using MediatR;

namespace B.T.Smark.APIRead.Applications.CommandHandler
{
    public class UserQueryCommandHandler : IRequestHandler<UserQueryCommand, APIResult<List<UserInfor>>>
    {
        public UserQueryCommandHandler(IBaseRepository<UserInfor> Users)
        {
            this.Users = Users;
        }

        public IBaseRepository<UserInfor> Users { get; }

        public async Task<APIResult<List<UserInfor>>> Handle(UserQueryCommand request, CancellationToken cancellationToken)
        {
            var path = Users.GetAll().ToList();
            return new APIResult<List<UserInfor>>()
            {
                Code = ResultCode.success,
                Mag = "",
                Data = path
            };
        }
    }
}
